home *** CD-ROM | disk | FTP | other *** search
- PROGRAM ShowEGA(input,output,picfile);
-
- { Copyright (c) 1987, Ciarcia's Circuit Cellar }
- { All Rights Reserved }
-
- { Version 1.01 May 12, 1987 }
- { Fixed SendEGA so it would work with more types }
- { of EGA boards. kwd }
-
- { shows image on EGA display using fixed "color" levels }
-
- {$U- control-break checking during execution }
- {$C- control-break checking during I/O operations }
- {$R- array range checking }
-
- {$Ideclares.p declarations }
- {$Ihexutil.p hex utilities }
- {$Iserial.p serial interface code }
- {$Ipictures.p picture file code }
- {$Iimages.p image processing }
-
- CONST
- EGAint = $10; { EGA video services }
- graymax = 9; { # gray shades - 1 }
-
- TYPE
- crng = 0..graymax; { gray scale index }
- cmaptype = ARRAY[bitrng] OF crng;
-
- VAR
- r : regrec;
- cmap : cmaptype;
-
- {--- Assign EGA colors }
- { histogram is available if needed... }
-
- PROCEDURE ShadeEGA(pic : picptr;
- VAR cmap : cmaptype);
-
- VAR
- bin : bitrng; { index into bins }
-
- BEGIN
-
- Writeln('Assigning colors');
-
- FOR bin := 0 TO maxbit DO BEGIN
- CASE bin OF
- 0.. 3 : cmap[bin] := 0;
- 4.. 9 : cmap[bin] := 1;
- 10..16 : cmap[bin] := 2;
- 17..24 : cmap[bin] := 3;
- 25..31 : cmap[bin] := 4;
- 32..38 : cmap[bin] := 5;
- 39..46 : cmap[bin] := 6;
- 47..53 : cmap[bin] := 7;
- 54..59 : cmap[bin] := 8;
- 60..63 : cmap[bin] := 9;
- END;
- END;
-
- END;
-
-
- {--- Show picture on EGA }
- { two EGA pels are used for each image pel to }
- { improve aspect ratio and allow for gray dithering }
-
- PROCEDURE SendEGA(pic : picptr;
- cmap : cmaptype);
-
- VAR
- r : regrec; { BIOS interface regs }
- row,col : INTEGER; { EGA coordinates }
- lndx : linerng; { line number }
- pndx : pelrng; { pel number }
- pelval1 : INTEGER; { pel value left }
- pelval2 : INTEGER; { pel value right }
-
- BEGIN
-
- r.AX := ($00 SHL 8) OR $10; { 640 x 350 / 16 colors }
- Intr(EGAint,r);
-
- row := 50;
- FOR lndx := 0 TO maxline DO BEGIN
- col := 64;
- FOR pndx := 0 TO maxpel DO BEGIN
- CASE cmap[pic^.fmt.lines[lndx].pels[pndx]] OF
- 0 : BEGIN
- pelval1 := 0;
- pelval2 := 0;
- END;
- 1 : BEGIN
- pelval1 := 0;
- pelval2 := 8;
- END;
- 2 : BEGIN
- pelval1 := 8;
- pelval2 := 8;
- END;
- 3 : BEGIN
- pelval1 := 8;
- pelval2 := 7;
- END;
- 4 : BEGIN
- pelval1 := 0;
- pelval2 := 7;
- END;
- 5 : BEGIN
- pelval1 := 7;
- pelval2 := 7;
- END;
- 6 : BEGIN
- pelval1 := 0;
- pelval2 := 15;
- END;
- 7 : BEGIN
- pelval1 := 8;
- pelval2 := 15;
- END;
- 8 : BEGIN
- pelval1 := 7;
- pelval2 := 15;
- END;
- 9 : BEGIN
- pelval1 := 15;
- pelval2 := 15;
- END;
- ELSE BEGIN
- pelval1 := 14;
- pelval2 := 14;
- END;
- END;
- r.AH := $0C;
- r.AL := pelval1;
- r.BX := $0000;
- r.CX := col;
- r.DX := row;
- Intr(EGAint,r);
- col := Succ(col);
- r.AH := $0C;
- r.AL := pelval2;
- r.BX := $0000;
- r.CX := col;
- r.DX := row;
- Intr(EGAint,r);
- col := Succ(col);
- END;
- row := Succ(row);
- IF KeyPressed
- THEN BEGIN
- TextMode;
- HALT;
- END;
- END;
-
- END;
-
- {--- Main routine }
-
- BEGIN
-
-
- pic1 := NIL; { ensure new alloc }
- PicSetup(pic1); { set up picture array }
-
- filespec := GetFSpec(ParamStr(1));
-
- LoadPicture(filespec,pic1); { read picture }
-
- ShadeEGA(pic1,cmap); { determine color map }
-
- SendEGA(pic1,cmap); { send mapped picture }
-
- GoToXY(1,24);
- Writeln('Press Enter');
- Readln;
- TextMode;
-
- END.